/**
 * Usado com a marcacao de AAAbarra
 * depende do jQuery
 * by Fabio Issamu Oshiro
 */
function Contraste(){
	var barra = document.getElementById("AAAbarra");
	if(!barra){
		barra = document.createElement("div");
		barra.setAttribute("id","AAAbarra");
		document.getElementsByTagName("body")[0].appendChild(barra);
	}
	this.ul = barra.getElementsByTagName("ul");
	if($.cookie("AAAstyle") && $.cookie("AAAstyle")!=""){
		var ln = document.createElement("link");
		ln.setAttribute("href",$.cookie("AAAstyle"));
		ln.setAttribute("rel","stylesheet");
		ln.setAttribute("type","text/css");
		ln.setAttribute("title","dinamico");
		document.getElementsByTagName("head")[0].appendChild(ln);
	}
	if(this.ul && this.ul.length>0){
		this.ul = this.ul[0];
	}else{
		this.ul = document.createElement("ul");
		barra.appendChild(this.ul);
	}
	this.setFundoPreto = function(v){
		var li = document.createElement("li");
		var a = document.createElement("a");
		a.setAttribute("id","AAAcontraste");
		a.setAttribute("href","#fundoPreto");
		if(typeof($.cookie("AAAstyle")) !="undefined" && v==$.cookie("AAAstyle")){
			$(a).addClass("AAAcolorido");
		}else{
			$(a).addClass("AAAcontraste");
		}
		a.onclick = function(){
			if(v==$.cookie("AAAstyle")){//desligar
				$.cookie("AAAstyle",null);
				var lns = document.getElementsByTagName("link");
				for(var i=0;i<lns.length;i++){
					try{
						if("dinamico"==lns[i].title){
							lns[i].disabled = true;
							document.removeChild(lns[i]);
						}
					}catch(e){
					}
				}
				$("#AAAcontraste").removeClass("AAAcolorido");
				$("#AAAcontraste").addClass("AAAcontraste");
			}else{
				var ln = document.createElement("link");
				ln.setAttribute("href",v);
				ln.setAttribute("title","dinamico");
				ln.setAttribute("rel","stylesheet");
				ln.setAttribute("type","text/css");
				document.getElementsByTagName("head")[0].appendChild(ln);
				$.cookie("AAAstyle", v, { expires: 7 });
				$("#AAAcontraste").removeClass("AAAcontraste");
				$("#AAAcontraste").addClass("AAAcolorido");
				$("#AAAcontraste2").removeClass("AAAcolorido");
				$("#AAAcontraste2").addClass("AAAcontraste2");
			}
		};
		li.appendChild(a);
		this.ul.appendChild(li);
	};
	this.setFundoBranco = function(v){
		var li = document.createElement("li");
		var a = document.createElement("a");
		a.setAttribute("id","AAAcontraste2");
		a.setAttribute("href","#fundoBranco");
		if(typeof($.cookie("AAAstyle")) !="undefined" && v==$.cookie("AAAstyle")){
			$(a).addClass("AAAcolorido");
		}else{
			$(a).addClass("AAAcontraste2");	
		}
		a.onclick = function(){
			if(v==$.cookie("AAAstyle")){
				$.cookie("AAAstyle",null);
				var lns = document.getElementsByTagName("link");
				for(var i=0;i<lns.length;i++){
					try{
						if("dinamico"==lns[i].title){
							lns[i].disabled = true;
							document.removeChild(lns[i]);
						}
					}catch(e){
					}
				}
				$("#AAAcontraste2").removeClass("AAAcolorido");
				$("#AAAcontraste2").addClass("AAAcontraste2");
			}else{
				var ln = document.createElement("link");
				ln.setAttribute("href",v);
				ln.setAttribute("title","dinamico");
				ln.setAttribute("rel","stylesheet");
				ln.setAttribute("type","text/css");
				document.getElementsByTagName("head")[0].appendChild(ln);
				$.cookie("AAAstyle", v, { expires: 7 });
				$("#AAAcontraste2").removeClass("AAAcontraste2");
				$("#AAAcontraste2").addClass("AAAcolorido");
				$("#AAAcontraste").removeClass("AAAcolorido");
				$("#AAAcontraste").addClass("AAAcontraste");
			}
		};
		li.appendChild(a);
		this.ul.appendChild(li);
	};
}
